roey.angel@bc.cas.cz

Alpha diversity analysis

This analysis explores the alpha-diversity distribution patters in the different samples, based on the DADA2-produced sequences.

Setting general parameters:

set.seed(1000)
subsamples <- 1000
min_lib_size <- 5000
metadata_path <- "./"
data_path <- "./DADA2_pseudo/"
Ps_file <- "TeaTime4Schools_ITS_filt.RDS"
Proj_name <- "TeaTime4Schools"

Load phyloseq object

This phyloseq object was created in 05_Taxonomical_analysis.html. The Ps_obj_filt object excludes contaminants and all sequences classified as eukaryota, chloroplast, mitochondria or unknown but still includes taxa with low prevalence

Ps_obj_filt <- readRDS(file = paste0(data_path, Ps_file))
Ps_obj_filt %>%
  subset_samples(., sample_sums(Ps_obj_filt) > min_lib_size) %>% # drop samples below min_lib_size
  subset_samples(., Field != "Unburied") %>% # drop unburied samples
  filter_taxa(., function(x)
    sum(x) > 0, TRUE) -> # remove taxa with 0 abundance
  Ps_obj_filt_subset

Ps_obj_filt_subset %>% 
  get_variable() %>% 
  mutate_at(., "Sample.type", 
            ~fct_relevel(., levels = c("Soil", "Green tea", "Rooibos"))) %>% 
  mutate_at(., "Season", 
            ~fct_relevel(., levels = c("Winter", "Spring", "Summer", "Autumn"))) %>% 
  arrange(Field, Sample.type, Season, Replicate) %>% 
  pull(Description) %>% 
  as.character() ->
  Sample.order

Richness

# tic()
abundance_mat <- as(otu_table(Ps_obj_filt_subset), "matrix") # use Ps_obj_filt_subset - no contaminants, no euk, chloro, mito, unknowns
## Original data
Original <-
  data.frame(Reads = rowSums(abundance_mat),
             S = apply(abundance_mat, 1, function(x)
               sum(x > 0)))

# Assign rarefaction mat  
rarefaction_mat <- 
  matrix(0, nrow = nrow(abundance_mat), ncol = subsamples)
rownames(rarefaction_mat) <- rownames(abundance_mat)

# Declare richness est table
rich.ests <-
  list(
  S.obs = rarefaction_mat,
  S.chao1 = rarefaction_mat,
  se.chao1 = rarefaction_mat,
  S.ACE = rarefaction_mat,
  se.ACE = rarefaction_mat
  )

# Rarefy abundance_mat and calc estimates
for (i in seq(subsamples)) {
  sub.OTUmat <-
    rrarefy(abundance_mat, min(rowSums(abundance_mat)))
    # rrarefy(abundance_mat, quantile(rowSums(abundance_mat), probs = seq(0, 1, rare2quant))[2])
  for (j in seq(length(rich.ests))) {
    rich.ests[[j]][, i] <- t(estimateR(sub.OTUmat))[, j]
  }
}

# Calculate means and SEM of subsamples
Richness <- data.frame(row.names = row.names(rich.ests[[1]]))
for (i in c(1, seq(2, length(rich.ests), 2))) {
  S <- apply(rich.ests[[i]], 1, mean)
  if (i == 1) {
    se <-
      apply(rich.ests[[i]], 1, function(x)
        (mean(x) / sqrt(length(x))))
  } else
    se <- apply(rich.ests[[i + 1]], 1, mean)
  Richness <- cbind(Richness, S, se)
}
colnames(Richness) <-
  c("S.obs.Estimate",
    "S.obs.SE",
    "S.chao1.Estimate",
    "S.chao1.SE",
    "S.ACE.Estimate",
    "S.ACE.SE")

Merge tables and save richness results

# Richness.Table <- cbind(Richness, parametric)
# Richness.Table <- Richness # only
saveRDS(cbind(Original, Richness),
        file = paste0(Proj_name, "_Richness.RDS"))
write.csv(cbind(Original, Richness),
        file = paste0(Proj_name, "_Richness.csv"))

Plot richness estimates

Richness %>% 
  rownames_to_column(var = "Sample") %>% # get sample names
  mutate_at(., "Sample", ~str_replace_all(., "Green_tea", "Green tea")) %>% #
  mutate_at(., "Sample", ~fct_relevel(., levels = Sample.order)) %>% 
  bind_cols(., get_variable(Ps_obj_filt_subset, 
                            c("Lib.size", "Field", "Sample.type", "Season", "Replicate"))) %>% # add metadata
  pivot_longer(cols = c(-"Sample", -"Lib.size", -"Field", -"Sample.type", -"Season", -"Replicate"), 
               names_to = c("Metric", ".value"), 
               values_to = c("Estimate", "SE"), 
               names_pattern = "(.*\\..*)\\.(.*)") %>% # gather all metrices to one column
  mutate_at(., "Season", 
            ~fct_relevel(., levels = c("Winter", "Spring", "Summer", "Autumn"))) %>% 

  mutate_at(., "Metric", ~fct_recode(., `Observed S` = "S.obs", Chao1 = "S.chao1", ACE = "S.ACE")) %>% 
  mutate(Estimate, herr = Estimate + SE, lerr = Estimate - SE) ->
  Richness_long

PlotSummarySingle_overlay(Richness_long)

fit <- lm(Estimate ~ Lib.size, 
                        data = Richness_long[Richness_long$Metric == "Observed S", ])
fit$model$Sample <- str_replace(Richness_long[Richness_long$Metric == "Observed S", ]$Sample, "(.*)_[0-9]$", "\\1")

ggplot(fit$model, aes_string(x = names(fit$model)[2], y = names(fit$model)[1])) + 
  geom_point(aes(colour = fit$model$Sample)) +
  stat_smooth(method = "lm", col = "red") +
  labs(title = paste("Adj R2 = ",signif(summary(fit)$adj.r.squared, 5),
                     "; Intercept =",signif(fit$coef[[1]], 5),
                     "; Slope =",signif(fit$coef[[2]], 5),
                     "; P =",signif(summary(fit)$coef[2,4], 5))) +
  theme(plot.title = element_text(size = 8)) + 
  theme(legend.position = "none")

PlotSummarySingle_overlay(x = "Season", Richness_long) + 
  facet_grid(Field ~ Sample.type) 

Combine replicates

Richness_long %>%
  group_by(Field, Season, Sample.type, Metric) %>%
  summarise(
    Mean = mean(Estimate),
    lerr = Mean - (sd(Estimate)) / sqrt(length(Estimate)),
    herr = Mean + (sd(Estimate)) / sqrt(length(Estimate))
  ) ->
  Combined_Richness_long

# plot
PlotSummarySingle_overlay(x = "Season", y = "Mean", Combined_Richness_long) + 
  facet_grid(Field ~ Sample.type) 

Diversity

# calculate diversity indices
# declare diversity indices table
diversity.inds <-
  list(Shannon = rarefaction_mat,
       inv.simpson = rarefaction_mat,
       BP = rarefaction_mat)
# rarefy abundance_mat and calc estimates
for (i in seq(subsamples)) {
  sub.OTUmat <-
    rrarefy(abundance_mat, min(rowSums(abundance_mat)))
    # rrarefy(abundance_mat, quantile(rowSums(abundance_mat), probs = seq(0, 1, rare2quant))[2])
  diversity.inds$Shannon[, i] <-
    diversityresult(sub.OTUmat,
                    index = 'Shannon' ,
                    method = 'each site',
                    digits = 3)[, 1]
  diversity.inds$inv.simpson[, i] <-
    diversityresult(sub.OTUmat,
                    index = 'inverseSimpson' ,
                    method = 'each site',
                    digits = 3)[, 1]
  diversity.inds$BP[, i] <-
    diversityresult(sub.OTUmat,
                    index = 'Berger' ,
                    method = 'each site',
                    digits = 3)[, 1]
}
# calculate means and SEM of subsamples
Diversity <-
  data.frame(row.names = row.names(diversity.inds[[1]]))
for (i in seq(length(diversity.inds))) {
  S <- apply(diversity.inds[[i]], 1, mean)
  se <-
    apply(diversity.inds[[i]], 1, function(x)
      (mean(x) / sqrt(length(x))))
  Diversity <- cbind(Diversity, S, se)
}
colnames(Diversity) <-
  c("Shannon.Estimate",
    "Shannon.SE",
    "InvSimpson.Estimate",
    "InvSimpson.SE",
    "BP.Estimate",
    "BP.SE")

Save diversity results

saveRDS(Diversity, file = paste0(Proj_name, "_Diversity.RDS"))
write.csv(Diversity, file = paste0(Proj_name, "_Diversity.csv"))

Plot diversity indices

Diversity %>% 
  rownames_to_column(var = "Sample") %>% # get sample names
  mutate_at(., "Sample", ~str_replace_all(., "Green_tea", "Green tea")) %>% #
  mutate_at(., "Sample", ~fct_relevel(., levels = Sample.order)) %>% 
  bind_cols(., get_variable(Ps_obj_filt_subset, 
                            c("Lib.size", "Field", "Sample.type", "Season", "Replicate"))) %>% # add metadata
  pivot_longer(cols = c(-"Sample", -"Lib.size", -"Field", -"Sample.type", -"Season", -"Replicate"), 
               names_to = c("Metric", ".value"), 
               values_to = c("Estimate", "SE"), 
               names_pattern = "(.*)\\.(.*)") %>% # gather all metrices to one column
  mutate_at(., "Season", 
            ~fct_relevel(., levels = c("Winter", "Spring", "Summer", "Autumn"))) %>% 
  mutate_at(., "Metric", ~fct_recode(., "Inv. Simpson" = "InvSimpson", "Berger Parker" = "BP")) %>% 
  mutate(Estimate, herr = Estimate + SE, lerr = Estimate - SE) ->
  Diversity_long

PlotSummarySingle(Diversity_long, y = "Estimate", colour = "Metric") + 
  background_grid(major = "y", minor = "none", size.major = 0.8) 

PlotSummarySingle(Diversity_long, x = "Season", y = "Estimate", colour = "Metric") + 
  facet_grid(Metric ~ Sample.type, scale = "free") + 
  background_grid(major = "y", minor = "none", size.major = 0.8)

Combine replicates

Diversity_long %>%
  group_by(Field, Season, Sample.type, Metric) %>%
  summarise(
    Mean = mean(Estimate),
    lerr = Mean - (sd(Estimate)) / sqrt(length(Estimate)),
    herr = Mean + (sd(Estimate)) / sqrt(length(Estimate))
  ) ->
  Combined_Diversity_long

# plot
p <- PlotSummarySingle(Combined_Diversity_long, x = "Sample.type", y = "Mean", colour = "Metric") 
p$layers[[1]] <- NULL
p +
  geom_point(aes_string(colour = "Metric", shape = "Season"), size = 3) +
  facet_grid(Metric ~ Field, scales = "free") + 
  background_grid(major = "y", minor = "none", size.major = 0.8) 

(mod_obsS <- TestAlphaV3(filter(Richness_Diversity_long, Metric == "Observed S")))
## Call:
##    aov(formula = as.formula(paste(response_name, paste(factor_names[1], 
##     factor_names[2], sep = " * "), sep = " ~ ")), data = data2test)
## 
## Terms:
##                 Sample.type Season Sample.type:Season Residuals
## Sum of Squares       826668  58912               9484    132159
## Deg. of Freedom           2      3                  6       109
## 
## Residual standard error: 34.8
## Estimated effects may be unbalanced

## [1] "Unequal group sizes - showing SS type III"
## Anova Table (Type III tests)
## 
## Response: Estimate
##                    Sum Sq  Df F value  Pr(>F)    
## (Intercept)         60231   1   49.68 1.7e-10 ***
## Sample.type        281178   2  115.95 < 2e-16 ***
## Season              12837   3    3.53   0.017 *  
## Sample.type:Season   9484   6    1.30   0.262    
## Residuals          132159 109                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Tables of means
## Grand mean
##     
## 132 
## 
##  Sample.type 
##     Green tea Rooibos Soil
##          73.5    95.2  275
## rep      45.0    46.0   30
## 
##  Season 
##     Autumn Spring Summer Winter
##        137    114    109    165
## rep     33     28     30     30
## 
##  Sample.type:Season 
##            Season
## Sample.type Autumn Spring Summer Winter
##   Green tea  71     61     58    100   
##   rep        12     11     10     12   
##   Rooibos   100     75     79    124   
##   rep        12     11     11     12   
##   Soil      291    253    236    331   
##   rep         9      6      9      6
## Call:
##    aov(formula = as.formula(paste(response_name, paste(factor_names[1], 
##     factor_names[2], sep = " * "), sep = " ~ ")), data = data2test)
## 
## Terms:
##                 Sample.type Season Sample.type:Season Residuals
## Sum of Squares       826668  58912               9484    132159
## Deg. of Freedom           2      3                  6       109
## 
## Residual standard error: 34.8
## Estimated effects may be unbalanced
# Post-hoc test
marginal <- emmeans(mod_obsS,
                   ~ Sample.type : Season)
summary(marginal)
##  Sample.type Season emmean   SE  df lower.CL upper.CL
##  Green tea   Autumn     71 10.1 109     50.9       91
##  Rooibos     Autumn    100 10.1 109     79.6      119
##  Soil        Autumn    291 11.6 109    267.6      314
##  Green tea   Spring     61 10.5 109     40.1       82
##  Rooibos     Spring     75 10.5 109     54.4       96
##  Soil        Spring    253 14.2 109    224.6      281
##  Green tea   Summer     58 11.0 109     36.3       80
##  Rooibos     Summer     79 10.5 109     58.3      100
##  Soil        Summer    236 11.6 109    212.5      259
##  Green tea   Winter    100 10.1 109     80.4      120
##  Rooibos     Winter    124 10.1 109    104.1      144
##  Soil        Winter    331 14.2 109    303.0      359
## 
## Confidence level used: 0.95
contrast(marginal, 
         method = "pairwise", 
         adjust = "tukey")
##  contrast                            estimate   SE  df t.ratio p.value
##  Green tea Autumn - Rooibos Autumn      -28.7 14.2 109  -2.020 0.6790 
##  Green tea Autumn - Soil Autumn        -219.8 15.3 109 -14.310 <.0001 
##  Green tea Autumn - Green tea Spring      9.9 14.5 109   0.680 1.0000 
##  Green tea Autumn - Rooibos Spring       -4.4 14.5 109  -0.300 1.0000 
##  Green tea Autumn - Soil Spring        -181.9 17.4 109 -10.450 <.0001 
##  Green tea Autumn - Green tea Summer     12.7 14.9 109   0.850 0.9990 
##  Green tea Autumn - Rooibos Summer       -8.3 14.5 109  -0.570 1.0000 
##  Green tea Autumn - Soil Summer        -164.7 15.3 109 -10.730 <.0001 
##  Green tea Autumn - Green tea Winter    -29.5 14.2 109  -2.080 0.6400 
##  Green tea Autumn - Rooibos Winter      -53.2 14.2 109  -3.740 0.0150 
##  Green tea Autumn - Soil Winter        -260.3 17.4 109 -14.950 <.0001 
##  Rooibos Autumn - Soil Autumn          -191.1 15.3 109 -12.440 <.0001 
##  Rooibos Autumn - Green tea Spring       38.6 14.5 109   2.660 0.2630 
##  Rooibos Autumn - Rooibos Spring         24.3 14.5 109   1.670 0.8760 
##  Rooibos Autumn - Soil Spring          -153.2 17.4 109  -8.800 <.0001 
##  Rooibos Autumn - Green tea Summer       41.4 14.9 109   2.780 0.2040 
##  Rooibos Autumn - Rooibos Summer         20.4 14.5 109   1.410 0.9600 
##  Rooibos Autumn - Soil Summer          -136.0 15.3 109  -8.860 <.0001 
##  Rooibos Autumn - Green tea Winter       -0.8 14.2 109  -0.060 1.0000 
##  Rooibos Autumn - Rooibos Winter        -24.5 14.2 109  -1.720 0.8550 
##  Rooibos Autumn - Soil Winter          -231.6 17.4 109 -13.300 <.0001 
##  Soil Autumn - Green tea Spring         229.7 15.7 109  14.680 <.0001 
##  Soil Autumn - Rooibos Spring           215.4 15.7 109  13.760 <.0001 
##  Soil Autumn - Soil Spring               37.9 18.4 109   2.060 0.6480 
##  Soil Autumn - Green tea Summer         232.5 16.0 109  14.530 <.0001 
##  Soil Autumn - Rooibos Summer           211.5 15.7 109  13.510 <.0001 
##  Soil Autumn - Soil Summer               55.1 16.4 109   3.360 0.0480 
##  Soil Autumn - Green tea Winter         190.3 15.3 109  12.390 <.0001 
##  Soil Autumn - Rooibos Winter           166.6 15.3 109  10.850 <.0001 
##  Soil Autumn - Soil Winter              -40.6 18.4 109  -2.210 0.5460 
##  Green tea Spring - Rooibos Spring      -14.3 14.8 109  -0.960 0.9980 
##  Green tea Spring - Soil Spring        -191.8 17.7 109 -10.850 <.0001 
##  Green tea Spring - Green tea Summer      2.8 15.2 109   0.190 1.0000 
##  Green tea Spring - Rooibos Summer      -18.2 14.8 109  -1.220 0.9860 
##  Green tea Spring - Soil Summer        -174.6 15.7 109 -11.150 <.0001 
##  Green tea Spring - Green tea Winter    -39.4 14.5 109  -2.710 0.2350 
##  Green tea Spring - Rooibos Winter      -63.1 14.5 109  -4.340 0.0020 
##  Green tea Spring - Soil Winter        -270.2 17.7 109 -15.290 <.0001 
##  Rooibos Spring - Soil Spring          -177.5 17.7 109 -10.050 <.0001 
##  Rooibos Spring - Green tea Summer       17.1 15.2 109   1.120 0.9930 
##  Rooibos Spring - Rooibos Summer         -3.9 14.8 109  -0.260 1.0000 
##  Rooibos Spring - Soil Summer          -160.3 15.7 109 -10.240 <.0001 
##  Rooibos Spring - Green tea Winter      -25.1 14.5 109  -1.730 0.8500 
##  Rooibos Spring - Rooibos Winter        -48.8 14.5 109  -3.360 0.0480 
##  Rooibos Spring - Soil Winter          -256.0 17.7 109 -14.480 <.0001 
##  Soil Spring - Green tea Summer         194.6 18.0 109  10.820 <.0001 
##  Soil Spring - Rooibos Summer           173.6 17.7 109   9.820 <.0001 
##  Soil Spring - Soil Summer               17.2 18.4 109   0.940 0.9990 
##  Soil Spring - Green tea Winter         152.4 17.4 109   8.750 <.0001 
##  Soil Spring - Rooibos Winter           128.7 17.4 109   7.390 <.0001 
##  Soil Spring - Soil Winter              -78.4 20.1 109  -3.900 0.0090 
##  Green tea Summer - Rooibos Summer      -21.0 15.2 109  -1.380 0.9650 
##  Green tea Summer - Soil Summer        -177.4 16.0 109 -11.090 <.0001 
##  Green tea Summer - Green tea Winter    -42.2 14.9 109  -2.830 0.1810 
##  Green tea Summer - Rooibos Winter      -65.9 14.9 109  -4.420 0.0010 
##  Green tea Summer - Soil Winter        -273.1 18.0 109 -15.190 <.0001 
##  Rooibos Summer - Soil Summer          -156.4 15.7 109  -9.990 <.0001 
##  Rooibos Summer - Green tea Winter      -21.2 14.5 109  -1.460 0.9480 
##  Rooibos Summer - Rooibos Winter        -44.9 14.5 109  -3.090 0.0980 
##  Rooibos Summer - Soil Winter          -252.1 17.7 109 -14.260 <.0001 
##  Soil Summer - Green tea Winter         135.2 15.3 109   8.800 <.0001 
##  Soil Summer - Rooibos Winter           111.5 15.3 109   7.260 <.0001 
##  Soil Summer - Soil Winter              -95.7 18.4 109  -5.210 <.0001 
##  Green tea Winter - Rooibos Winter      -23.7 14.2 109  -1.660 0.8800 
##  Green tea Winter - Soil Winter        -230.8 17.4 109 -13.260 <.0001 
##  Rooibos Winter - Soil Winter          -207.2 17.4 109 -11.900 <.0001 
## 
## P value adjustment: tukey method for comparing a family of 12 estimates
(obsS_pairwise <- cld(marginal,
                      alpha = 0.05,
                      Letters = letters,
                      adjust = "tukey")) # works with lm but not with two-factor ART
##  Sample.type Season emmean   SE  df lower.CL upper.CL .group
##  Green tea   Summer     58 11.0 109     26.0       90  a    
##  Green tea   Spring     61 10.5 109     30.3       92  a    
##  Green tea   Autumn     71 10.1 109     41.5      100  a    
##  Rooibos     Spring     75 10.5 109     44.6      106  a    
##  Rooibos     Summer     79 10.5 109     48.5      110  ab   
##  Rooibos     Autumn    100 10.1 109     70.2      129  ab   
##  Green tea   Winter    100 10.1 109     71.0      130  ab   
##  Rooibos     Winter    124 10.1 109     94.7      153   b   
##  Soil        Summer    236 11.6 109    201.7      269    c  
##  Soil        Spring    253 14.2 109    211.2      294    cd 
##  Soil        Autumn    291 11.6 109    256.8      325     de
##  Soil        Winter    331 14.2 109    289.7      373      e
## 
## Confidence level used: 0.95 
## Conf-level adjustment: sidak method for 12 estimates 
## P value adjustment: tukey method for comparing a family of 12 estimates 
## significance level used: alpha = 0.05
(mod_obsS %>% 
  anova() %>% 
  mutate(`Part Eta Sq`=`Sum Sq`/sum(`Sum Sq`) ) ->
  mod_obsS_ANOVA)
## Analysis of Variance Table
## 
## Response: Estimate
##                     Df Sum Sq Mean Sq F value Pr(>F) Part Eta Sq
## Sample.type          2 826668  413334   340.9  0.000       0.805
## Season               3  58912   19637    16.2  0.000       0.057
## Sample.type:Season   6   9484    1581     1.3  0.262       0.009
## Residuals          109 132159    1212                      0.129
# pwpp(marginal) # Pairwise P-value plot. Fails for unbalanced design
emmip(mod_obsS, Sample.type ~ Season)

# summary(as.glht(pairs(marginal))) # fails because of unbalanced design

(mod_S <- TestAlphaV3(filter(Richness_Diversity_long, Metric == "Shannon")))
## Call:
##    aov(formula = as.formula(paste(response_name, paste(factor_names[1], 
##     factor_names[2], sep = " * "), sep = " ~ ")), data = data2test)
## 
## Terms:
##                 Sample.type Season Sample.type:Season Residuals
## Sum of Squares         59.3    2.2                0.9      28.9
## Deg. of Freedom           2      3                  6       109
## 
## Residual standard error: 0.515
## Estimated effects may be unbalanced

## [1] "Unequal group sizes - showing SS type III"
## Anova Table (Type III tests)
## 
## Response: Estimate
##                    Sum Sq  Df F value Pr(>F)    
## (Intercept)          1028   1 3874.26 <2e-16 ***
## Sample.type            58   2  108.95 <2e-16 ***
## Season                  2   3    2.48  0.065 .  
## Sample.type:Season      1   6    0.55  0.766    
## Residuals              29 109                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Tables of means
## Grand mean
##      
## 2.86 
## 
##  Sample.type 
##     Green tea Rooibos  Soil
##          2.31    2.62  4.06
## rep     45.00   46.00 30.00
## 
##  Season 
##     Autumn Spring Summer Winter
##       2.76    2.7   3.01   2.99
## rep  33.00   28.0  30.00  30.00
## 
##  Sample.type:Season 
##            Season
## Sample.type Autumn Spring Summer Winter
##   Green tea  2.34   2.16   2.40   2.35 
##   rep       12.00  11.00  10.00  12.00 
##   Rooibos    2.39   2.40   2.88   2.82 
##   rep       12.00  11.00  11.00  12.00 
##   Soil       3.95   3.99   4.13   4.21 
##   rep        9.00   6.00   9.00   6.00
## Call:
##    aov(formula = as.formula(paste(response_name, paste(factor_names[1], 
##     factor_names[2], sep = " * "), sep = " ~ ")), data = data2test)
## 
## Terms:
##                 Sample.type Season Sample.type:Season Residuals
## Sum of Squares         59.3    2.2                0.9      28.9
## Deg. of Freedom           2      3                  6       109
## 
## Residual standard error: 0.515
## Estimated effects may be unbalanced
# Post-hoc test
marginal <- emmeans(mod_S,
                   ~ Sample.type : Season)
summary(marginal)
##  Sample.type Season emmean    SE  df lower.CL upper.CL
##  Green tea   Autumn   2.34 0.149 109     2.04     2.63
##  Rooibos     Autumn   2.39 0.149 109     2.09     2.68
##  Soil        Autumn   3.95 0.172 109     3.61     4.29
##  Green tea   Spring   2.16 0.155 109     1.86     2.47
##  Rooibos     Spring   2.40 0.155 109     2.09     2.71
##  Soil        Spring   3.99 0.210 109     3.57     4.40
##  Green tea   Summer   2.40 0.163 109     2.08     2.73
##  Rooibos     Summer   2.88 0.155 109     2.58     3.19
##  Soil        Summer   4.13 0.172 109     3.79     4.47
##  Green tea   Winter   2.35 0.149 109     2.06     2.65
##  Rooibos     Winter   2.82 0.149 109     2.53     3.12
##  Soil        Winter   4.21 0.210 109     3.79     4.63
## 
## Confidence level used: 0.95
contrast(marginal, 
         method = "pairwise", 
         adjust = "tukey")
##  contrast                            estimate    SE  df t.ratio p.value
##  Green tea Autumn - Rooibos Autumn     -0.050 0.210 109 -0.240  1.0000 
##  Green tea Autumn - Soil Autumn        -1.607 0.227 109 -7.080  <.0001 
##  Green tea Autumn - Green tea Spring    0.175 0.215 109  0.820  1.0000 
##  Green tea Autumn - Rooibos Spring     -0.062 0.215 109 -0.290  1.0000 
##  Green tea Autumn - Soil Spring        -1.647 0.258 109 -6.390  <.0001 
##  Green tea Autumn - Green tea Summer   -0.065 0.221 109 -0.290  1.0000 
##  Green tea Autumn - Rooibos Summer     -0.545 0.215 109 -2.530  0.3310 
##  Green tea Autumn - Soil Summer        -1.787 0.227 109 -7.870  <.0001 
##  Green tea Autumn - Green tea Winter   -0.014 0.210 109 -0.070  1.0000 
##  Green tea Autumn - Rooibos Winter     -0.482 0.210 109 -2.290  0.4870 
##  Green tea Autumn - Soil Winter        -1.872 0.258 109 -7.270  <.0001 
##  Rooibos Autumn - Soil Autumn          -1.558 0.227 109 -6.860  <.0001 
##  Rooibos Autumn - Green tea Spring      0.225 0.215 109  1.050  0.9960 
##  Rooibos Autumn - Rooibos Spring       -0.013 0.215 109 -0.060  1.0000 
##  Rooibos Autumn - Soil Spring          -1.597 0.258 109 -6.200  <.0001 
##  Rooibos Autumn - Green tea Summer     -0.015 0.221 109 -0.070  1.0000 
##  Rooibos Autumn - Rooibos Summer       -0.495 0.215 109 -2.300  0.4810 
##  Rooibos Autumn - Soil Summer          -1.738 0.227 109 -7.650  <.0001 
##  Rooibos Autumn - Green tea Winter      0.036 0.210 109  0.170  1.0000 
##  Rooibos Autumn - Rooibos Winter       -0.433 0.210 109 -2.060  0.6530 
##  Rooibos Autumn - Soil Winter          -1.822 0.258 109 -7.070  <.0001 
##  Soil Autumn - Green tea Spring         1.783 0.232 109  7.700  <.0001 
##  Soil Autumn - Rooibos Spring           1.545 0.232 109  6.670  <.0001 
##  Soil Autumn - Soil Spring             -0.039 0.272 109 -0.140  1.0000 
##  Soil Autumn - Green tea Summer         1.543 0.237 109  6.520  <.0001 
##  Soil Autumn - Rooibos Summer           1.062 0.232 109  4.590  0.0010 
##  Soil Autumn - Soil Summer             -0.180 0.243 109 -0.740  1.0000 
##  Soil Autumn - Green tea Winter         1.593 0.227 109  7.010  <.0001 
##  Soil Autumn - Rooibos Winter           1.125 0.227 109  4.950  <.0001 
##  Soil Autumn - Soil Winter             -0.265 0.272 109 -0.980  0.9980 
##  Green tea Spring - Rooibos Spring     -0.238 0.220 109 -1.080  0.9950 
##  Green tea Spring - Soil Spring        -1.822 0.262 109 -6.970  <.0001 
##  Green tea Spring - Green tea Summer   -0.240 0.225 109 -1.070  0.9950 
##  Green tea Spring - Rooibos Summer     -0.720 0.220 109 -3.280  0.0590 
##  Green tea Spring - Soil Summer        -1.963 0.232 109 -8.480  <.0001 
##  Green tea Spring - Green tea Winter   -0.190 0.215 109 -0.880  0.9990 
##  Green tea Spring - Rooibos Winter     -0.658 0.215 109 -3.060  0.1060 
##  Green tea Spring - Soil Winter        -2.048 0.262 109 -7.830  <.0001 
##  Rooibos Spring - Soil Spring          -1.584 0.262 109 -6.060  <.0001 
##  Rooibos Spring - Green tea Summer     -0.002 0.225 109 -0.010  1.0000 
##  Rooibos Spring - Rooibos Summer       -0.483 0.220 109 -2.200  0.5560 
##  Rooibos Spring - Soil Summer          -1.725 0.232 109 -7.450  <.0001 
##  Rooibos Spring - Green tea Winter      0.048 0.215 109  0.220  1.0000 
##  Rooibos Spring - Rooibos Winter       -0.420 0.215 109 -1.950  0.7230 
##  Rooibos Spring - Soil Winter          -1.810 0.262 109 -6.920  <.0001 
##  Soil Spring - Green tea Summer         1.582 0.266 109  5.950  <.0001 
##  Soil Spring - Rooibos Summer           1.102 0.262 109  4.210  0.0030 
##  Soil Spring - Soil Summer             -0.141 0.272 109 -0.520  1.0000 
##  Soil Spring - Green tea Winter         1.632 0.258 109  6.340  <.0001 
##  Soil Spring - Rooibos Winter           1.164 0.258 109  4.520  0.0010 
##  Soil Spring - Soil Winter             -0.226 0.297 109 -0.760  1.0000 
##  Green tea Summer - Rooibos Summer     -0.480 0.225 109 -2.130  0.6000 
##  Green tea Summer - Soil Summer        -1.723 0.237 109 -7.280  <.0001 
##  Green tea Summer - Green tea Winter    0.050 0.221 109  0.230  1.0000 
##  Green tea Summer - Rooibos Winter     -0.418 0.221 109 -1.890  0.7600 
##  Green tea Summer - Soil Winter        -1.808 0.266 109 -6.790  <.0001 
##  Rooibos Summer - Soil Summer          -1.242 0.232 109 -5.360  <.0001 
##  Rooibos Summer - Green tea Winter      0.531 0.215 109  2.470  0.3710 
##  Rooibos Summer - Rooibos Winter        0.062 0.215 109  0.290  1.0000 
##  Rooibos Summer - Soil Winter          -1.327 0.262 109 -5.080  <.0001 
##  Soil Summer - Green tea Winter         1.773 0.227 109  7.800  <.0001 
##  Soil Summer - Rooibos Winter           1.305 0.227 109  5.740  <.0001 
##  Soil Summer - Soil Winter             -0.085 0.272 109 -0.310  1.0000 
##  Green tea Winter - Rooibos Winter     -0.468 0.210 109 -2.230  0.5350 
##  Green tea Winter - Soil Winter        -1.858 0.258 109 -7.210  <.0001 
##  Rooibos Winter - Soil Winter          -1.390 0.258 109 -5.390  <.0001 
## 
## P value adjustment: tukey method for comparing a family of 12 estimates
(Shannon_pairwise <- cld(marginal,
                      alpha = 0.05,
                      Letters = letters,
                      adjust = "tukey")) # works with lm but not with two-factor ART
##  Sample.type Season emmean    SE  df lower.CL upper.CL .group
##  Green tea   Spring   2.16 0.155 109     1.71     2.62  a    
##  Green tea   Autumn   2.34 0.149 109     1.90     2.77  a    
##  Green tea   Winter   2.35 0.149 109     1.92     2.79  a    
##  Rooibos     Autumn   2.39 0.149 109     1.95     2.82  a    
##  Rooibos     Spring   2.40 0.155 109     1.95     2.85  a    
##  Green tea   Summer   2.40 0.163 109     1.93     2.88  a    
##  Rooibos     Winter   2.82 0.149 109     2.39     3.26  a    
##  Rooibos     Summer   2.88 0.155 109     2.43     3.34  a    
##  Soil        Autumn   3.95 0.172 109     3.44     4.45   b   
##  Soil        Spring   3.99 0.210 109     3.37     4.60   b   
##  Soil        Summer   4.13 0.172 109     3.62     4.63   b   
##  Soil        Winter   4.21 0.210 109     3.60     4.82   b   
## 
## Confidence level used: 0.95 
## Conf-level adjustment: sidak method for 12 estimates 
## P value adjustment: tukey method for comparing a family of 12 estimates 
## significance level used: alpha = 0.05
(mod_S %>% 
  anova() %>% 
  mutate(`Part Eta Sq`=`Sum Sq`/sum(`Sum Sq`) ) ->
  mod_S_ANOVA)
## Analysis of Variance Table
## 
## Response: Estimate
##                     Df Sum Sq Mean Sq F value Pr(>F) Part Eta Sq
## Sample.type          2   59.3   29.63  111.63  0.000       0.649
## Season               3    2.2    0.74    2.79  0.044       0.024
## Sample.type:Season   6    0.9    0.15    0.55  0.766       0.010
## Residuals          109   28.9    0.27                      0.317
# pwpp(marginal) # Pairwise P-value plot. Fails for unbalanced design
emmip(mod_S, Sample.type ~ Season)

# summary(as.glht(pairs(marginal))) # fails because of unbalanced design

(mod_IS <- TestAlphaV3(filter(Richness_Diversity_long, Metric == "Inv. Simpson")))
## Call:
##    aov(formula = as.formula(paste(response_name, paste(factor_names[1], 
##     factor_names[2], sep = " * "), sep = " ~ ")), data = data2test)
## 
## Terms:
##                 Sample.type Season Sample.type:Season Residuals
## Sum of Squares         7898    208                310      4261
## Deg. of Freedom           2      3                  6       109
## 
## Residual standard error: 6.25
## Estimated effects may be unbalanced

## [1] "Unequal group sizes - showing SS type III"
## Anova Table (Type III tests)
## 
## Response: Estimate
##                    Sum Sq  Df F value Pr(>F)    
## (Intercept)         21664   1  554.18 <2e-16 ***
## Sample.type          7868   2  100.64 <2e-16 ***
## Season                281   3    2.40  0.072 .  
## Sample.type:Season    310   6    1.32  0.253    
## Residuals            4261 109                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Tables of means
## Grand mean
##      
## 12.1 
## 
##  Sample.type 
##     Green tea Rooibos Soil
##          5.94     9.1   26
## rep     45.00    46.0   30
## 
##  Season 
##     Autumn Spring Summer Winter
##       10.8     11   13.8     13
## rep   33.0     28   30.0     30
## 
##  Sample.type:Season 
##            Season
## Sample.type Autumn Spring Summer Winter
##   Green tea  6.70   4.88   6.86   5.40 
##   rep       12.00  11.00  10.00  12.00 
##   Rooibos    8.25   8.08  10.67   9.45 
##   rep       12.00  11.00  11.00  12.00 
##   Soil      21.10  24.38  28.64  30.90 
##   rep        9.00   6.00   9.00   6.00
## Call:
##    aov(formula = as.formula(paste(response_name, paste(factor_names[1], 
##     factor_names[2], sep = " * "), sep = " ~ ")), data = data2test)
## 
## Terms:
##                 Sample.type Season Sample.type:Season Residuals
## Sum of Squares         7898    208                310      4261
## Deg. of Freedom           2      3                  6       109
## 
## Residual standard error: 6.25
## Estimated effects may be unbalanced
# Post-hoc test
marginal <- emmeans(mod_IS,
                   ~ Sample.type : Season)
summary(marginal)
##  Sample.type Season emmean   SE  df lower.CL upper.CL
##  Green tea   Autumn   6.70 1.80 109     3.13     10.3
##  Rooibos     Autumn   8.25 1.80 109     4.68     11.8
##  Soil        Autumn  21.10 2.08 109    16.97     25.2
##  Green tea   Spring   4.88 1.89 109     1.14      8.6
##  Rooibos     Spring   8.08 1.89 109     4.35     11.8
##  Soil        Spring  24.38 2.55 109    19.32     29.4
##  Green tea   Summer   6.86 1.98 109     2.94     10.8
##  Rooibos     Summer  10.67 1.89 109     6.94     14.4
##  Soil        Summer  28.64 2.08 109    24.51     32.8
##  Green tea   Winter   5.40 1.80 109     1.82      9.0
##  Rooibos     Winter   9.45 1.80 109     5.87     13.0
##  Soil        Winter  30.90 2.55 109    25.84     36.0
## 
## Confidence level used: 0.95
contrast(marginal, 
         method = "pairwise", 
         adjust = "tukey")
##  contrast                            estimate   SE  df t.ratio p.value
##  Green tea Autumn - Rooibos Autumn      -1.55 2.55 109 -0.610  1.0000 
##  Green tea Autumn - Soil Autumn        -14.40 2.76 109 -5.220  <.0001 
##  Green tea Autumn - Green tea Spring     1.82 2.61 109  0.700  1.0000 
##  Green tea Autumn - Rooibos Spring      -1.38 2.61 109 -0.530  1.0000 
##  Green tea Autumn - Soil Spring        -17.68 3.13 109 -5.650  <.0001 
##  Green tea Autumn - Green tea Summer    -0.15 2.68 109 -0.060  1.0000 
##  Green tea Autumn - Rooibos Summer      -3.97 2.61 109 -1.520  0.9320 
##  Green tea Autumn - Soil Summer        -21.94 2.76 109 -7.960  <.0001 
##  Green tea Autumn - Green tea Winter     1.31 2.55 109  0.510  1.0000 
##  Green tea Autumn - Rooibos Winter      -2.74 2.55 109 -1.070  0.9950 
##  Green tea Autumn - Soil Winter        -24.19 3.13 109 -7.740  <.0001 
##  Rooibos Autumn - Soil Autumn          -12.85 2.76 109 -4.660  0.0010 
##  Rooibos Autumn - Green tea Spring       3.37 2.61 109  1.290  0.9780 
##  Rooibos Autumn - Rooibos Spring         0.17 2.61 109  0.060  1.0000 
##  Rooibos Autumn - Soil Spring          -16.13 3.13 109 -5.160  <.0001 
##  Rooibos Autumn - Green tea Summer       1.39 2.68 109  0.520  1.0000 
##  Rooibos Autumn - Rooibos Summer        -2.42 2.61 109 -0.930  0.9990 
##  Rooibos Autumn - Soil Summer          -20.39 2.76 109 -7.400  <.0001 
##  Rooibos Autumn - Green tea Winter       2.86 2.55 109  1.120  0.9930 
##  Rooibos Autumn - Rooibos Winter        -1.19 2.55 109 -0.470  1.0000 
##  Rooibos Autumn - Soil Winter          -22.65 3.13 109 -7.240  <.0001 
##  Soil Autumn - Green tea Spring         16.23 2.81 109  5.770  <.0001 
##  Soil Autumn - Rooibos Spring           13.02 2.81 109  4.630  0.0010 
##  Soil Autumn - Soil Spring              -3.28 3.30 109 -0.990  0.9980 
##  Soil Autumn - Green tea Summer         14.25 2.87 109  4.960  <.0001 
##  Soil Autumn - Rooibos Summer           10.43 2.81 109  3.710  0.0160 
##  Soil Autumn - Soil Summer              -7.54 2.95 109 -2.560  0.3170 
##  Soil Autumn - Green tea Winter         15.71 2.76 109  5.700  <.0001 
##  Soil Autumn - Rooibos Winter           11.66 2.76 109  4.230  0.0030 
##  Soil Autumn - Soil Winter              -9.79 3.30 109 -2.970  0.1310 
##  Green tea Spring - Rooibos Spring      -3.20 2.67 109 -1.200  0.9880 
##  Green tea Spring - Soil Spring        -19.50 3.17 109 -6.150  <.0001 
##  Green tea Spring - Green tea Summer    -1.98 2.73 109 -0.720  1.0000 
##  Green tea Spring - Rooibos Summer      -5.79 2.67 109 -2.170  0.5730 
##  Green tea Spring - Soil Summer        -23.76 2.81 109 -8.460  <.0001 
##  Green tea Spring - Green tea Winter    -0.52 2.61 109 -0.200  1.0000 
##  Green tea Spring - Rooibos Winter      -4.57 2.61 109 -1.750  0.8410 
##  Green tea Spring - Soil Winter        -26.02 3.17 109 -8.200  <.0001 
##  Rooibos Spring - Soil Spring          -16.30 3.17 109 -5.140  <.0001 
##  Rooibos Spring - Green tea Summer       1.23 2.73 109  0.450  1.0000 
##  Rooibos Spring - Rooibos Summer        -2.59 2.67 109 -0.970  0.9980 
##  Rooibos Spring - Soil Summer          -20.56 2.81 109 -7.320  <.0001 
##  Rooibos Spring - Green tea Winter       2.69 2.61 109  1.030  0.9970 
##  Rooibos Spring - Rooibos Winter        -1.36 2.61 109 -0.520  1.0000 
##  Rooibos Spring - Soil Winter          -22.81 3.17 109 -7.190  <.0001 
##  Soil Spring - Green tea Summer         17.52 3.23 109  5.430  <.0001 
##  Soil Spring - Rooibos Summer           13.71 3.17 109  4.320  0.0020 
##  Soil Spring - Soil Summer              -4.26 3.30 109 -1.290  0.9780 
##  Soil Spring - Green tea Winter         18.98 3.13 109  6.070  <.0001 
##  Soil Spring - Rooibos Winter           14.93 3.13 109  4.780  <.0001 
##  Soil Spring - Soil Winter              -6.52 3.61 109 -1.810  0.8110 
##  Green tea Summer - Rooibos Summer      -3.81 2.73 109 -1.400  0.9620 
##  Green tea Summer - Soil Summer        -21.78 2.87 109 -7.580  <.0001 
##  Green tea Summer - Green tea Winter     1.46 2.68 109  0.550  1.0000 
##  Green tea Summer - Rooibos Winter      -2.59 2.68 109 -0.970  0.9980 
##  Green tea Summer - Soil Winter        -24.04 3.23 109 -7.450  <.0001 
##  Rooibos Summer - Soil Summer          -17.97 2.81 109 -6.390  <.0001 
##  Rooibos Summer - Green tea Winter       5.28 2.61 109  2.020  0.6780 
##  Rooibos Summer - Rooibos Winter         1.23 2.61 109  0.470  1.0000 
##  Rooibos Summer - Soil Winter          -20.23 3.17 109 -6.370  <.0001 
##  Soil Summer - Green tea Winter         23.25 2.76 109  8.430  <.0001 
##  Soil Summer - Rooibos Winter           19.20 2.76 109  6.960  <.0001 
##  Soil Summer - Soil Winter              -2.26 3.30 109 -0.680  1.0000 
##  Green tea Winter - Rooibos Winter      -4.05 2.55 109 -1.590  0.9100 
##  Green tea Winter - Soil Winter        -25.50 3.13 109 -8.160  <.0001 
##  Rooibos Winter - Soil Winter          -21.45 3.13 109 -6.860  <.0001 
## 
## P value adjustment: tukey method for comparing a family of 12 estimates
(InvSim_pairwise <- cld(marginal,
                      alpha = 0.05,
                      Letters = letters,
                      adjust = "tukey")) # works with lm but not with two-factor ART
##  Sample.type Season emmean   SE  df lower.CL upper.CL .group
##  Green tea   Spring   4.88 1.89 109    -0.62     10.4  a    
##  Green tea   Winter   5.40 1.80 109     0.13     10.7  a    
##  Green tea   Autumn   6.70 1.80 109     1.44     12.0  a    
##  Green tea   Summer   6.86 1.98 109     1.09     12.6  a    
##  Rooibos     Spring   8.08 1.89 109     2.58     13.6  a    
##  Rooibos     Autumn   8.25 1.80 109     2.98     13.5  a    
##  Rooibos     Winter   9.45 1.80 109     4.18     14.7  a    
##  Rooibos     Summer  10.67 1.89 109     5.17     16.2  a    
##  Soil        Autumn  21.10 2.08 109    15.02     27.2   b   
##  Soil        Spring  24.38 2.55 109    16.93     31.8   b   
##  Soil        Summer  28.64 2.08 109    22.56     34.7   b   
##  Soil        Winter  30.90 2.55 109    23.45     38.3   b   
## 
## Confidence level used: 0.95 
## Conf-level adjustment: sidak method for 12 estimates 
## P value adjustment: tukey method for comparing a family of 12 estimates 
## significance level used: alpha = 0.05
(mod_IS %>% 
  anova() %>% 
  mutate(`Part Eta Sq`=`Sum Sq`/sum(`Sum Sq`) ) ->
  mod_IS_ANOVA)
## Analysis of Variance Table
## 
## Response: Estimate
##                     Df Sum Sq Mean Sq F value Pr(>F) Part Eta Sq
## Sample.type          2   7898    3949  101.03  0.000       0.623
## Season               3    208      69    1.77  0.156       0.016
## Sample.type:Season   6    310      52    1.32  0.253       0.024
## Residuals          109   4261      39                      0.336
# pwpp(marginal) # Pairwise P-value plot. Fails for unbalanced design
emmip(mod_IS, Sample.type ~ Season)

# summary(as.glht(pairs(marginal))) # fails because of unbalanced design

(mod_BP <- TestAlphaV3(filter(Richness_Diversity_long, Metric == "Berger Parker")))
## Call:
##    aov(formula = as.formula(paste(response_name, paste(factor_names[1], 
##     factor_names[2], sep = " * "), sep = " ~ ")), data = data2test)
## 
## Terms:
##                 Sample.type Season Sample.type:Season Residuals
## Sum of Squares        0.854  0.132              0.128     2.172
## Deg. of Freedom           2      3                  6       109
## 
## Residual standard error: 0.141
## Estimated effects may be unbalanced

## [1] "Unequal group sizes - showing SS type III"
## Anova Table (Type III tests)
## 
## Response: Estimate
##                    Sum Sq  Df F value  Pr(>F)    
## (Intercept)          7.86   1  394.56 < 2e-16 ***
## Sample.type          0.82   2   20.46 2.9e-08 ***
## Season               0.12   3    1.99    0.12    
## Sample.type:Season   0.13   6    1.07    0.38    
## Residuals            2.17 109                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Tables of means
## Grand mean
##      
## 0.28 
## 
##  Sample.type 
##     Green tea Rooibos   Soil
##         0.354   0.299  0.139
## rep    45.000  46.000 30.000
## 
##  Season 
##     Autumn Spring Summer Winter
##      0.304  0.299  0.223  0.293
## rep 33.000 28.000 30.000 30.000
## 
##  Sample.type:Season 
##            Season
## Sample.type Autumn Spring Summer Winter
##   Green tea  0.33   0.37   0.27   0.42 
##   rep       12.00  11.00  10.00  12.00 
##   Rooibos    0.36   0.33   0.23   0.27 
##   rep       12.00  11.00  11.00  12.00 
##   Soil       0.17   0.14   0.12   0.13 
##   rep        9.00   6.00   9.00   6.00
## Call:
##    aov(formula = as.formula(paste(response_name, paste(factor_names[1], 
##     factor_names[2], sep = " * "), sep = " ~ ")), data = data2test)
## 
## Terms:
##                 Sample.type Season Sample.type:Season Residuals
## Sum of Squares        0.854  0.132              0.128     2.172
## Deg. of Freedom           2      3                  6       109
## 
## Residual standard error: 0.141
## Estimated effects may be unbalanced
# Post-hoc test
marginal <- emmeans(mod_BP,
                   ~ Sample.type : Season)
summary(marginal)
##  Sample.type Season emmean     SE  df lower.CL upper.CL
##  Green tea   Autumn  0.334 0.0407 109    0.253    0.415
##  Rooibos     Autumn  0.365 0.0407 109    0.284    0.445
##  Soil        Autumn  0.165 0.0471 109    0.072    0.259
##  Green tea   Spring  0.373 0.0426 109    0.289    0.458
##  Rooibos     Spring  0.327 0.0426 109    0.243    0.412
##  Soil        Spring  0.141 0.0576 109    0.027    0.256
##  Green tea   Summer  0.274 0.0446 109    0.185    0.362
##  Rooibos     Summer  0.232 0.0426 109    0.148    0.317
##  Soil        Summer  0.120 0.0471 109    0.026    0.213
##  Green tea   Winter  0.422 0.0407 109    0.341    0.503
##  Rooibos     Winter  0.268 0.0407 109    0.188    0.349
##  Soil        Winter  0.128 0.0576 109    0.013    0.242
## 
## Confidence level used: 0.95
contrast(marginal, 
         method = "pairwise", 
         adjust = "tukey")
##  contrast                            estimate     SE  df t.ratio p.value
##  Green tea Autumn - Rooibos Autumn    -0.0308 0.0576 109 -0.530  1.0000 
##  Green tea Autumn - Soil Autumn        0.1685 0.0622 109  2.710  0.2370 
##  Green tea Autumn - Green tea Spring  -0.0394 0.0589 109 -0.670  1.0000 
##  Green tea Autumn - Rooibos Spring     0.0066 0.0589 109  0.110  1.0000 
##  Green tea Autumn - Soil Spring        0.1925 0.0706 109  2.730  0.2270 
##  Green tea Autumn - Green tea Summer   0.0602 0.0604 109  1.000  0.9970 
##  Green tea Autumn - Rooibos Summer     0.1015 0.0589 109  1.720  0.8540 
##  Green tea Autumn - Soil Summer        0.2143 0.0622 109  3.440  0.0370 
##  Green tea Autumn - Green tea Winter  -0.0881 0.0576 109 -1.530  0.9290 
##  Green tea Autumn - Rooibos Winter     0.0654 0.0576 109  1.140  0.9920 
##  Green tea Autumn - Soil Winter        0.2062 0.0706 109  2.920  0.1480 
##  Rooibos Autumn - Soil Autumn          0.1992 0.0622 109  3.200  0.0730 
##  Rooibos Autumn - Green tea Spring    -0.0086 0.0589 109 -0.150  1.0000 
##  Rooibos Autumn - Rooibos Spring       0.0374 0.0589 109  0.630  1.0000 
##  Rooibos Autumn - Soil Spring          0.2233 0.0706 109  3.160  0.0810 
##  Rooibos Autumn - Green tea Summer     0.0910 0.0604 109  1.510  0.9360 
##  Rooibos Autumn - Rooibos Summer       0.1323 0.0589 109  2.240  0.5220 
##  Rooibos Autumn - Soil Summer          0.2451 0.0622 109  3.940  0.0080 
##  Rooibos Autumn - Green tea Winter    -0.0573 0.0576 109 -1.000  0.9980 
##  Rooibos Autumn - Rooibos Winter       0.0962 0.0576 109  1.670  0.8780 
##  Rooibos Autumn - Soil Winter          0.2370 0.0706 109  3.360  0.0480 
##  Soil Autumn - Green tea Spring       -0.2078 0.0634 109 -3.280  0.0600 
##  Soil Autumn - Rooibos Spring         -0.1618 0.0634 109 -2.550  0.3210 
##  Soil Autumn - Soil Spring             0.0241 0.0744 109  0.320  1.0000 
##  Soil Autumn - Green tea Summer       -0.1082 0.0649 109 -1.670  0.8780 
##  Soil Autumn - Rooibos Summer         -0.0670 0.0634 109 -1.060  0.9960 
##  Soil Autumn - Soil Summer             0.0458 0.0665 109  0.690  1.0000 
##  Soil Autumn - Green tea Winter       -0.2566 0.0622 109 -4.120  0.0040 
##  Soil Autumn - Rooibos Winter         -0.1030 0.0622 109 -1.660  0.8840 
##  Soil Autumn - Soil Winter             0.0378 0.0744 109  0.510  1.0000 
##  Green tea Spring - Rooibos Spring     0.0460 0.0602 109  0.760  1.0000 
##  Green tea Spring - Soil Spring        0.2319 0.0716 109  3.240  0.0670 
##  Green tea Spring - Green tea Summer   0.0996 0.0617 109  1.620  0.9000 
##  Green tea Spring - Rooibos Summer     0.1409 0.0602 109  2.340  0.4550 
##  Green tea Spring - Soil Summer        0.2537 0.0634 109  4.000  0.0060 
##  Green tea Spring - Green tea Winter  -0.0487 0.0589 109 -0.830  1.0000 
##  Green tea Spring - Rooibos Winter     0.1048 0.0589 109  1.780  0.8260 
##  Green tea Spring - Soil Winter        0.2456 0.0716 109  3.430  0.0390 
##  Rooibos Spring - Soil Spring          0.1859 0.0716 109  2.590  0.2960 
##  Rooibos Spring - Green tea Summer     0.0536 0.0617 109  0.870  0.9990 
##  Rooibos Spring - Rooibos Summer       0.0949 0.0602 109  1.580  0.9140 
##  Rooibos Spring - Soil Summer          0.2077 0.0634 109  3.270  0.0600 
##  Rooibos Spring - Green tea Winter    -0.0947 0.0589 109 -1.610  0.9030 
##  Rooibos Spring - Rooibos Winter       0.0588 0.0589 109  1.000  0.9970 
##  Rooibos Spring - Soil Winter          0.1996 0.0716 109  2.790  0.2010 
##  Soil Spring - Green tea Summer       -0.1323 0.0729 109 -1.810  0.8070 
##  Soil Spring - Rooibos Summer         -0.0910 0.0716 109 -1.270  0.9810 
##  Soil Spring - Soil Summer             0.0218 0.0744 109  0.290  1.0000 
##  Soil Spring - Green tea Winter       -0.2806 0.0706 109 -3.980  0.0070 
##  Soil Spring - Rooibos Winter         -0.1271 0.0706 109 -1.800  0.8140 
##  Soil Spring - Soil Winter             0.0137 0.0815 109  0.170  1.0000 
##  Green tea Summer - Rooibos Summer     0.0412 0.0617 109  0.670  1.0000 
##  Green tea Summer - Soil Summer        0.1540 0.0649 109  2.380  0.4320 
##  Green tea Summer - Green tea Winter  -0.1484 0.0604 109 -2.450  0.3800 
##  Green tea Summer - Rooibos Winter     0.0052 0.0604 109  0.090  1.0000 
##  Green tea Summer - Soil Winter        0.1460 0.0729 109  2.000  0.6900 
##  Rooibos Summer - Soil Summer          0.1128 0.0634 109  1.780  0.8260 
##  Rooibos Summer - Green tea Winter    -0.1896 0.0589 109 -3.220  0.0700 
##  Rooibos Summer - Rooibos Winter      -0.0361 0.0589 109 -0.610  1.0000 
##  Rooibos Summer - Soil Winter          0.1048 0.0716 109  1.460  0.9470 
##  Soil Summer - Green tea Winter       -0.3024 0.0622 109 -4.860  <.0001 
##  Soil Summer - Rooibos Winter         -0.1489 0.0622 109 -2.390  0.4210 
##  Soil Summer - Soil Winter            -0.0080 0.0744 109 -0.110  1.0000 
##  Green tea Winter - Rooibos Winter     0.1535 0.0576 109  2.660  0.2580 
##  Green tea Winter - Soil Winter        0.2944 0.0706 109  4.170  0.0030 
##  Rooibos Winter - Soil Winter          0.1408 0.0706 109  2.000  0.6960 
## 
## P value adjustment: tukey method for comparing a family of 12 estimates
(BP_pairwise <- cld(marginal,
                      alpha = 0.05,
                      Letters = letters,
                      adjust = "tukey")) # works with lm but not with two-factor ART
##  Sample.type Season emmean     SE  df lower.CL upper.CL .group
##  Soil        Summer  0.120 0.0471 109  -0.0178    0.257  a    
##  Soil        Winter  0.128 0.0576 109  -0.0406    0.296  ab   
##  Soil        Spring  0.141 0.0576 109  -0.0269    0.310  abc  
##  Soil        Autumn  0.165 0.0471 109   0.0281    0.303  abc  
##  Rooibos     Summer  0.232 0.0426 109   0.1081    0.357  abcd 
##  Rooibos     Winter  0.268 0.0407 109   0.1495    0.387  abcd 
##  Green tea   Summer  0.274 0.0446 109   0.1433    0.404  abcd 
##  Rooibos     Spring  0.327 0.0426 109   0.2030    0.451  abcd 
##  Green tea   Autumn  0.334 0.0407 109   0.2149    0.453   bcd 
##  Rooibos     Autumn  0.365 0.0407 109   0.2457    0.484    cd 
##  Green tea   Spring  0.373 0.0426 109   0.2490    0.497    cd 
##  Green tea   Winter  0.422 0.0407 109   0.3030    0.541     d 
## 
## Confidence level used: 0.95 
## Conf-level adjustment: sidak method for 12 estimates 
## P value adjustment: tukey method for comparing a family of 12 estimates 
## significance level used: alpha = 0.05
(mod_BP %>% 
  anova() %>% 
  mutate(`Part Eta Sq`=`Sum Sq`/sum(`Sum Sq`) ) ->
  mod_BP_ANOVA)
## Analysis of Variance Table
## 
## Response: Estimate
##                     Df Sum Sq Mean Sq F value Pr(>F) Part Eta Sq
## Sample.type          2  0.854   0.427   21.44  0.000       0.260
## Season               3  0.132   0.044    2.21  0.091       0.040
## Sample.type:Season   6  0.128   0.021    1.07  0.385       0.039
## Residuals          109  2.172   0.020                      0.661
# pwpp(marginal) # Pairwise P-value plot. Fails for unbalanced design
emmip(mod_BP, Sample.type ~ Season)

# summary(as.glht(pairs(marginal))) # fails because of unbalanced design

Plot all alpha diversity metrics together

Richness_Diversity_long %>% 
  dplyr::filter(!Metric %in% c("Chao1", "ACE")) %>% 
  # mutate(across("Metric", ~fct_recode(., "Observed S" = "S obs.", "Inv. Simpson" = "Inv. Simpson", "Berger Parker" = "Berger Parker"))) %>% 
  mutate(across("Metric", ~fct_relevel(., "Observed S", "Inv. Simpson", "Shannon", "Berger Parker"))) %>% 
  mutate(across("Season", ~fct_relevel(., "Winter", "Spring", "Summer", "Autumn"))) %>% 
  droplevels() ->
  Richness_Diversity_long2plot
p_alpha <- ggplot() +
  geom_violin(data = Richness_Diversity_long2plot,
             aes(
               x = Sample.type,
               y = Estimate,
               ymin = lerr,
               ymax = herr
             ), colour = "grey",
              fill = "grey",
              alpha = 1 / 3) +
  geom_jitter(data = Richness_Diversity_long2plot,
               aes(x = Sample.type,
               y = Estimate,
               ymin = lerr,
               ymax = herr,
               colour = Field), size = 3, width = 0.2, alpha = 2/3) +
  # scale_colour_manual(values = Gradient.colours[c(5, 6, 11)], name = "") +
  scale_colour_locuszoom(name = "") +
  scale_fill_locuszoom(name = "") +
  # geom_errorbar(alpha = 1 / 2, width = 0.3) +
  xlab("") +
  ylab("") +
  theme(axis.text.x = element_text(
    angle = 45,
    vjust = 0.9,
    hjust = 1
  )) +
  facet_grid(Metric ~ Season, scale = "free") +
  theme(strip.text = element_text(size = f_size - 4)) +
  background_grid(major = "y",
                  minor = "none",
                  size.major = 0.8) 

bind_rows(`Observed S` = obsS_pairwise, 
          `Inv. Simpson` = InvSim_pairwise,
          Shannon = Shannon_pairwise,  
          `Berger Parker` = BP_pairwise, 
          .id = "Metric") %>% 
  bind_cols(., y = rep(c(550, 60, 5.5, 1.1), each = 12)) %>% 
  mutate(across(Metric, ~fct_inorder(.x))) ->
  dat_text

p_alpha <- p_alpha + geom_text(
  data = dat_text,
  mapping = aes(x = Sample.type, y = y, label = .group),
  nudge_x = 0,
  nudge_y = 0
)
print(p_alpha)

sessioninfo::session_info() %>%
  details::details(
    summary = 'Current session info',
    open    = TRUE
 )

Current session info


─ Session info ─────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 4.0.3 (2020-10-10)
 os       Ubuntu 18.04.5 LTS          
 system   x86_64, linux-gnu           
 ui       X11                         
 language en_GB                       
 collate  en_DK.UTF-8                 
 ctype    en_DK.UTF-8                 
 tz       Europe/Prague               
 date     2021-05-21                  

─ Packages ─────────────────────────────────────────────────────────────────────────────
 package       * version date       lib source        
 abind           1.4-5   2016-07-21 [1] CRAN (R 4.0.2)
 ade4            1.7-16  2020-10-28 [1] CRAN (R 4.0.2)
 ape             5.5     2021-04-25 [1] CRAN (R 4.0.3)
 assertthat      0.2.1   2019-03-21 [1] CRAN (R 4.0.2)
 backports       1.2.1   2020-12-09 [1] CRAN (R 4.0.2)
 base64enc       0.1-3   2015-07-28 [1] CRAN (R 4.0.2)
 Biobase         2.50.0  2020-10-27 [1] Bioconductor  
 BiocGenerics    0.36.1  2021-04-16 [1] Bioconductor  
 BiodiversityR * 2.13-1  2021-04-20 [1] CRAN (R 4.0.3)
 biomformat      1.18.0  2020-10-27 [1] Bioconductor  
 Biostrings      2.58.0  2020-10-27 [1] Bioconductor  
 boot            1.3-28  2021-05-03 [1] CRAN (R 4.0.3)
 broom         * 0.7.6   2021-04-05 [1] CRAN (R 4.0.3)
 bslib           0.2.5.1 2021-05-18 [1] CRAN (R 4.0.3)
 car           * 3.0-10  2020-09-29 [1] CRAN (R 4.0.2)
 carData       * 3.0-4   2020-05-22 [1] CRAN (R 4.0.2)
 cellranger      1.1.0   2016-07-27 [1] CRAN (R 4.0.2)
 checkmate       2.0.0   2020-02-06 [1] CRAN (R 4.0.2)
 class           7.3-19  2021-05-03 [1] CRAN (R 4.0.3)
 cli             2.5.0   2021-04-26 [1] CRAN (R 4.0.3)
 clipr           0.7.1   2020-10-08 [1] CRAN (R 4.0.2)
 cluster         2.1.2   2021-04-17 [1] CRAN (R 4.0.3)
 coda            0.19-4  2020-09-30 [1] CRAN (R 4.0.2)
 codetools       0.2-18  2020-11-04 [1] CRAN (R 4.0.2)
 coin            1.4-1   2021-02-08 [1] CRAN (R 4.0.3)
 colorspace      2.0-1   2021-05-04 [1] CRAN (R 4.0.3)
 cowplot       * 1.1.1   2020-12-30 [1] CRAN (R 4.0.2)
 crayon          1.4.1   2021-02-08 [1] CRAN (R 4.0.3)
 curl            4.3.1   2021-04-30 [1] CRAN (R 4.0.3)
 data.table      1.14.0  2021-02-21 [1] CRAN (R 4.0.3)
 DBI             1.1.1   2021-01-15 [1] CRAN (R 4.0.3)
 dbplyr          2.1.1   2021-04-06 [1] CRAN (R 4.0.3)
 desc            1.3.0   2021-03-05 [1] CRAN (R 4.0.3)
 DescTools       0.99.41 2021-04-10 [1] CRAN (R 4.0.3)
 details         0.2.1   2020-01-12 [1] CRAN (R 4.0.2)
 digest          0.6.27  2020-10-24 [1] CRAN (R 4.0.2)
 doParallel    * 1.0.16  2020-10-16 [1] CRAN (R 4.0.2)
 dplyr         * 1.0.6   2021-05-05 [1] CRAN (R 4.0.3)
 e1071           1.7-6   2021-03-18 [1] CRAN (R 4.0.3)
 effects         4.2-0   2020-08-11 [1] CRAN (R 4.0.2)
 ellipsis        0.3.2   2021-04-29 [1] CRAN (R 4.0.3)
 emmeans       * 1.6.0   2021-04-24 [1] CRAN (R 4.0.3)
 estimability    1.3     2018-02-11 [1] CRAN (R 4.0.2)
 evaluate        0.14    2019-05-28 [1] CRAN (R 4.0.2)
 Exact           2.1     2020-10-02 [1] CRAN (R 4.0.2)
 expm            0.999-6 2021-01-13 [1] CRAN (R 4.0.3)
 extrafont     * 0.17    2014-12-08 [1] CRAN (R 4.0.2)
 extrafontdb     1.0     2012-06-11 [1] CRAN (R 4.0.2)
 fansi           0.4.2   2021-01-15 [1] CRAN (R 4.0.3)
 farver          2.1.0   2021-02-28 [1] CRAN (R 4.0.3)
 forcats       * 0.5.1   2021-01-27 [1] CRAN (R 4.0.3)
 foreach       * 1.5.1   2020-10-15 [1] CRAN (R 4.0.2)
 foreign         0.8-81  2020-12-22 [4] CRAN (R 4.0.3)
 Formula         1.2-4   2020-10-16 [1] CRAN (R 4.0.2)
 fs              1.5.0   2020-07-31 [1] CRAN (R 4.0.2)
 generics        0.1.0   2020-10-31 [1] CRAN (R 4.0.2)
 ggplot2       * 3.3.3   2020-12-30 [1] CRAN (R 4.0.2)
 ggsci         * 2.9     2018-05-14 [1] CRAN (R 4.0.2)
 gld             2.6.2   2020-01-08 [1] CRAN (R 4.0.2)
 glue            1.4.2   2020-08-27 [1] CRAN (R 4.0.2)
 gridExtra     * 2.3     2017-09-09 [1] CRAN (R 4.0.2)
 gtable          0.3.0   2019-03-25 [1] CRAN (R 4.0.2)
 haven           2.4.1   2021-04-23 [1] CRAN (R 4.0.3)
 highr           0.9     2021-04-16 [1] CRAN (R 4.0.3)
 Hmisc           4.5-0   2021-02-28 [1] CRAN (R 4.0.3)
 hms             1.1.0   2021-05-17 [1] CRAN (R 4.0.3)
 htmlTable       2.2.1   2021-05-18 [1] CRAN (R 4.0.3)
 htmltools       0.5.1.1 2021-01-22 [1] CRAN (R 4.0.3)
 htmlwidgets     1.5.3   2020-12-10 [1] CRAN (R 4.0.2)
 httr            1.4.2   2020-07-20 [1] CRAN (R 4.0.2)
 igraph          1.2.6   2020-10-06 [1] CRAN (R 4.0.2)
 insight         0.14.0  2021-05-07 [1] CRAN (R 4.0.3)
 IRanges         2.24.1  2020-12-12 [1] Bioconductor  
 iterators     * 1.0.13  2020-10-15 [1] CRAN (R 4.0.2)
 jpeg            0.1-8.1 2019-10-24 [1] CRAN (R 4.0.2)
 jquerylib       0.1.4   2021-04-26 [1] CRAN (R 4.0.3)
 jsonlite        1.7.2   2020-12-09 [1] CRAN (R 4.0.2)
 kableExtra    * 1.3.4   2021-02-20 [1] CRAN (R 4.0.3)
 knitr         * 1.33    2021-04-24 [1] CRAN (R 4.0.3)
 labeling        0.4.2   2020-10-20 [1] CRAN (R 4.0.2)
 lattice       * 0.20-44 2021-05-02 [1] CRAN (R 4.0.3)
 latticeExtra    0.6-29  2019-12-19 [1] CRAN (R 4.0.2)
 libcoin         1.0-8   2021-02-08 [1] CRAN (R 4.0.3)
 lifecycle       1.0.0   2021-02-15 [1] CRAN (R 4.0.3)
 lme4            1.1-27  2021-05-15 [1] CRAN (R 4.0.3)
 lmom            2.8     2019-03-12 [1] CRAN (R 4.0.2)
 lmtest          0.9-38  2020-09-09 [1] CRAN (R 4.0.2)
 lubridate       1.7.10  2021-02-26 [1] CRAN (R 4.0.3)
 magrittr      * 2.0.1   2020-11-17 [1] CRAN (R 4.0.2)
 MASS          * 7.3-54  2021-05-03 [1] CRAN (R 4.0.3)
 Matrix          1.3-3   2021-05-04 [1] CRAN (R 4.0.3)
 matrixStats     0.58.0  2021-01-29 [1] CRAN (R 4.0.3)
 mgcv            1.8-35  2021-04-18 [1] CRAN (R 4.0.3)
 minqa           1.2.4   2014-10-09 [1] CRAN (R 4.0.2)
 mitools         2.4     2019-04-26 [1] CRAN (R 4.0.2)
 modelr          0.1.8   2020-05-19 [1] CRAN (R 4.0.2)
 modeltools      0.2-23  2020-03-05 [1] CRAN (R 4.0.2)
 multcomp      * 1.4-17  2021-04-29 [1] CRAN (R 4.0.3)
 multcompView    0.1-8   2019-12-19 [1] CRAN (R 4.0.2)
 multtest        2.46.0  2020-10-27 [1] Bioconductor  
 munsell         0.5.0   2018-06-12 [1] CRAN (R 4.0.2)
 mvtnorm       * 1.1-1   2020-06-09 [1] CRAN (R 4.0.2)
 nlme            3.1-152 2021-02-04 [1] CRAN (R 4.0.3)
 nloptr          1.2.2.2 2020-07-02 [1] CRAN (R 4.0.2)
 nnet            7.3-16  2021-05-03 [1] CRAN (R 4.0.3)
 nortest         1.0-4   2015-07-30 [1] CRAN (R 4.0.2)
 openxlsx        4.2.3   2020-10-27 [1] CRAN (R 4.0.2)
 permute       * 0.9-5   2019-03-12 [1] CRAN (R 4.0.2)
 phyloseq      * 1.34.0  2020-10-27 [1] Bioconductor  
 pillar          1.6.1   2021-05-16 [1] CRAN (R 4.0.3)
 pkgconfig       2.0.3   2019-09-22 [1] CRAN (R 4.0.2)
 plyr            1.8.6   2020-03-03 [1] CRAN (R 4.0.2)
 png             0.1-7   2013-12-03 [1] CRAN (R 4.0.2)
 prettyunits     1.1.1   2020-01-24 [1] CRAN (R 4.0.2)
 progress        1.2.2   2019-05-16 [1] CRAN (R 4.0.2)
 proxy           0.4-25  2021-03-05 [1] CRAN (R 4.0.3)
 ps              1.6.0   2021-02-28 [1] CRAN (R 4.0.3)
 purrr         * 0.3.4   2020-04-17 [1] CRAN (R 4.0.2)
 R6              2.5.0   2020-10-28 [1] CRAN (R 4.0.2)
 ragg          * 1.1.2   2021-03-17 [1] CRAN (R 4.0.3)
 Rcmdr           2.7-1   2020-10-07 [1] CRAN (R 4.0.2)
 RcmdrMisc       2.7-1   2020-08-13 [1] CRAN (R 4.0.2)
 RColorBrewer    1.1-2   2014-12-07 [1] CRAN (R 4.0.2)
 rcompanion    * 2.4.1   2021-05-18 [1] CRAN (R 4.0.3)
 Rcpp            1.0.6   2021-01-15 [1] CRAN (R 4.0.3)
 readr         * 1.4.0   2020-10-05 [1] CRAN (R 4.0.2)
 readxl          1.3.1   2019-03-13 [1] CRAN (R 4.0.2)
 relimp          1.0-5   2016-03-30 [1] CRAN (R 4.0.2)
 reprex          2.0.0   2021-04-02 [1] CRAN (R 4.0.3)
 reshape2        1.4.4   2020-04-09 [1] CRAN (R 4.0.2)
 rhdf5           2.34.0  2020-10-27 [1] Bioconductor  
 rhdf5filters    1.2.1   2021-05-03 [1] Bioconductor  
 Rhdf5lib        1.12.1  2021-01-26 [1] Bioconductor  
 rio             0.5.26  2021-03-01 [1] CRAN (R 4.0.3)
 rlang           0.4.11  2021-04-30 [1] CRAN (R 4.0.3)
 rmarkdown     * 2.8     2021-05-07 [1] CRAN (R 4.0.3)
 rootSolve       1.8.2.1 2020-04-27 [1] CRAN (R 4.0.2)
 rpart           4.1-15  2019-04-12 [1] CRAN (R 4.0.2)
 rprojroot       2.0.2   2020-11-15 [1] CRAN (R 4.0.2)
 rstudioapi      0.13    2020-11-12 [1] CRAN (R 4.0.2)
 Rttf2pt1        1.3.8   2020-01-10 [1] CRAN (R 4.0.2)
 rvest           1.0.0   2021-03-09 [1] CRAN (R 4.0.3)
 S4Vectors       0.28.1  2020-12-09 [1] Bioconductor  
 sandwich        3.0-1   2021-05-18 [1] CRAN (R 4.0.3)
 sass            0.4.0   2021-05-12 [1] CRAN (R 4.0.3)
 scales        * 1.1.1   2020-05-11 [1] CRAN (R 4.0.2)
 sessioninfo     1.1.1   2018-11-05 [1] CRAN (R 4.0.2)
 stringi         1.6.2   2021-05-17 [1] CRAN (R 4.0.3)
 stringr       * 1.4.0   2019-02-10 [1] CRAN (R 4.0.2)
 survey          4.0     2020-04-03 [1] CRAN (R 4.0.2)
 survival      * 3.2-11  2021-04-26 [1] CRAN (R 4.0.3)
 svglite       * 2.0.0   2021-02-20 [1] CRAN (R 4.0.3)
 systemfonts     1.0.2   2021-05-11 [1] CRAN (R 4.0.3)
 tcltk2          1.2-11  2014-12-20 [1] CRAN (R 4.0.2)
 textshaping     0.3.4   2021-05-11 [1] CRAN (R 4.0.3)
 TH.data       * 1.0-10  2019-01-21 [1] CRAN (R 4.0.2)
 tibble        * 3.1.2   2021-05-16 [1] CRAN (R 4.0.3)
 tidyr         * 1.1.3   2021-03-03 [1] CRAN (R 4.0.3)
 tidyselect      1.1.1   2021-04-30 [1] CRAN (R 4.0.3)
 tidyverse     * 1.3.1   2021-04-15 [1] CRAN (R 4.0.3)
 utf8            1.2.1   2021-03-12 [1] CRAN (R 4.0.3)
 vctrs           0.3.8   2021-04-29 [1] CRAN (R 4.0.3)
 vegan         * 2.5-7   2020-11-28 [1] CRAN (R 4.0.3)
 viridisLite     0.4.0   2021-04-13 [1] CRAN (R 4.0.3)
 webshot         0.5.2   2019-11-22 [1] CRAN (R 4.0.2)
 withr           2.4.2   2021-04-18 [1] CRAN (R 4.0.3)
 xfun            0.23    2021-05-15 [1] CRAN (R 4.0.3)
 xml2            1.3.2   2020-04-23 [1] CRAN (R 4.0.2)
 xtable          1.8-4   2019-04-21 [1] CRAN (R 4.0.2)
 XVector         0.30.0  2020-10-27 [1] Bioconductor  
 yaml            2.2.1   2020-02-01 [1] CRAN (R 4.0.2)
 zip             2.1.1   2020-08-27 [1] CRAN (R 4.0.2)
 zlibbioc        1.36.0  2020-10-27 [1] Bioconductor  
 zoo             1.8-9   2021-03-09 [1] CRAN (R 4.0.3)

[1] /home/angel/R/library
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library


References